<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加折扣</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <#assign base=request.contextPath  />
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css?t=1534970980648" media="all">
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <script src="${base}/frame/layui/layui.all.js" charset="utf-8"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
    <script src="${base}/js/jquery.min.js"></script>
    <script type="text/javascript" src="${base}/wangEdit/wangEditor.min.js"></script>
    <style type="text/css">
        form {
            padding: 20px;
        }

        .layui-btn-radius {
            border-radius: 5px;
        }

        .layui-table-cell {
            height: auto;
            white-space: normal;
        }
    </style>
</head>
<body>
<input type="hidden" value="${ids}" id="ids"/>
<form class="layui-form" action="">
    <#--<div class="layui-form-item">-->
        <#--<div class="layui-inline">-->
            <#--<label class="layui-form-label">站点名称</label>-->
            <#--<div class="layui-input-inline">-->
                <#--<textarea name="name" id="name" disabled style="width: 268px;height: 111px;" lay-verify="required" autocomplete="off" class="layui-input "-->
                          <#--type="text">${name}</textarea>-->
            <#--</div>-->

        <#--</div>-->
    <#--</div>-->
    <#--<div class="layui-form-item">-->
        <#--<div class="layui-inline">-->
            <#--<label class="layui-form-label">站点地址</label>-->
            <#--<div class="layui-input-inline">-->
                <#--<textarea name="address" id="address" disabled style="width: 268px;height: 111px;" lay-verify="required" autocomplete="off" class="layui-input "-->
                          <#--type="text">${address}</textarea>-->
            <#--</div>-->

        <#--</div>-->
    <#--</div>-->

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">优惠信息</label>
            <div class="layui-input-inline">
                <input name="discount" id="discount" lay-verify="required" autocomplete="off" class="layui-input "
                       type="text">
            </div>
        </div>
    </div>




    <div class="layui-form-item" style="text-align:center">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button" id="aa"
                    onclick="onSubmit()" style="background-color: #0092EF;text-align: center;">立即提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius" style="text-align: center;">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'layedit', 'laydate', 'layer','upload'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , upload = layui.upload
            , laydate = layui.laydate;
    })
</script>
<script>


    //添加
    function onSubmit() {

        $.ajax({
            type: "POST",
            url: "${base}/admin/apiDiscount/saveDiscount",
            data: {ids:$("#ids").val(),discount:$("#discount").val()},
            success: function (data) {
                if(data.code===200){
                    layer.msg(data.msg);
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }, 300)
                    var table = parent.layui.table;
                    //表刷新方法
                    table.reload('testReload', {
                        url: '${base}/admin/site/selectMyPage'
                        , where: {} //设定异步数据接口的额外参数
                        //,height: 300
                    });
                }else{
                    layer.msg(data.msg)
                }

            }
        });
    }

</script>

</body>
</html>
